package han.chensing.latos.maker.windows.dialog.base;

import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;

import han.chensing.latos.maker.res.Res;
import han.chensing.latos.maker.V;

public class BasicDialog extends BaseDialog {
    Label messageLabel;
    TextButton closeButton;

    public BasicDialog(String title,String text,int width,int height){
        super(title,false);
        Skin skin = Res.get().get("skinBasic", Skin.class);
        messageLabel=new Label(text, skin);
        setSize(width,height+messageLabel.getHeight()/2f);
        setPosition(V.WIDTH/2f-getWidth()/2,V.HEIGHT/2f-getHeight()/2);
        messageLabel.setAlignment(Align.center| Align.top);
        messageLabel.setWidth(getWidth());
        //messageLabel.setWrap(true);
        messageLabel.setPosition(0,getHeight()/1.8f-messageLabel.getHeight()/2);
        addActor(messageLabel);
        closeButton=new TextButton("OK",skin);
        closeButton.setSize(100,25);
        closeButton.setPosition(getWidth()/2-closeButton.getWidth()/2f,
                closeButton.getHeight()-15);
        addActor(closeButton);
        closeButton.addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
                BasicDialog.this.remove();
            }
        });
    }

    public BasicDialog(String title,String text) {
        this(title,text,514,114);
    }

}
